﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Xww.Task {
    public class BaseFileTask : IFileTask {

        protected int bufferSize = 204800;
        public virtual int BufferSize {
            get { return bufferSize; }
            set { bufferSize = value; }
        }

        public BaseFileTask(Action<IFileTask> excuteAction) {
            ExcuteAction = excuteAction;
        }

        public Action<IFileTask> ExcuteAction { get; set; }

        #region IFileTask 成员

        public string[] Sources {
            get;
            set;
        }
        public string Source {
            get { return Sources[0]; }
        }

        public string[] Dests {
            get;
            set;
        }
        public string Dest {
            get { return Dests[0]; }
        }

        public System.Text.Encoding InputEncoding { get; set; }
        public System.Text.Encoding OutputEncoding { get; set; }

        public bool ReporstProgress { get; set; }

        public EventHandler<ProgressStatus> ProgressChanged {
            get;
            set;
        }
        public virtual void Excute() {
            if (ExcuteAction != null)
                ExcuteAction(this);
        }

        #endregion
    }

}
